# -*- coding: UTF-8 -*-

import web
from web import form
from web.template import render

urls = (
    '/', 'index'
)

fileUpLoadFrom = form.Form(
    form.File('myfile', description="请选择要上传的文件"),
    form.Button('button', description="提交"),
)


class index:
    def GET(self):
        return """<html><head></head><body>
                    <form method="POST" enctype="multipart/form-data">
                    <input type="file" name="myfile" />
                    <br/>
                    <input type="submit" name="提交"/>
                    </form>
                    </body></html>"""

    def POST(self):
        x = web.input(myfile={})
        filename = x['myfile'].filename
        # data = x['myfile'].file.read()
        # web.debug(x['myfile'].filename) # 这里是文件名
        # web.debug(x['myfile'].value) # 这里是文件内容
        # web.debug(x['myfile'].file.read()) # 或者使用一个文件对象




if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()
